using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Chest : MonoBehaviour, IInteractable {

    private SpriteRenderer spriteRenderer;  // spriteRenderer组件
    public Sprite openSprite;               // 盒子打开的Sprite
    public Sprite closeSprite;              // 盒子关闭的Sprite
    public bool isDone;                     // 是否已经操作过了

    private void Awake() {
        spriteRenderer = GetComponent<SpriteRenderer>();
        isDone = false;
    }

    private void OnEnable() {
        spriteRenderer.sprite = isDone ? openSprite : closeSprite;
    }

    public void TriggerAction() {
        if (!isDone) {
            OpenCast();
        }
    }

    private void OpenCast() {
        spriteRenderer.sprite = openSprite;
        isDone = true;
        gameObject.tag = "Untagged";
    }

}
